package com.mz.ozy.adapter;

import android.widget.TextView;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mz.ozy.R;
import com.mz.ozy.bean.AddressBean;

import java.util.List;

/**
 * Created by administrator on 2018/11/21.
 */
public class AddressAdapter extends BaseQuickAdapter<AddressBean, BaseViewHolder> {

    public AddressAdapter(@Nullable List<AddressBean> data) {
        super(R.layout.item_address, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, AddressBean item) {
        helper.addOnClickListener(R.id.tv_default)
                .addOnClickListener(R.id.tv_edit)
                .addOnClickListener(R.id.tv_del);

        helper.setText(R.id.tv_name, item.getConsignee())
                .setText(R.id.tv_phone, item.getContactnumber())
                .setText(R.id.tv_address, item.getArea0name() + item.getArea1name() + item.getArea2name() + item.getXxaddress());

        TextView tvDefault = helper.getView(R.id.tv_default);
        tvDefault.setCompoundDrawablesWithIntrinsicBounds(
                mContext.getResources().getDrawable(item.getIsdefault() == 1 ? R.mipmap.cb_red_select : R.mipmap.cb_red_normal),
                null, null, null);

    }

}
